home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / arrayavg.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.1 KB  |  49 lines

  1. <!--- This view-only example shows the use of ArrayAvg --->
  2. <HTML>
  3. <HEAD>
  4. <TITLE>ArrayAvg Example</TITLE>
  5. </HEAD>
  6.  
  7. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  8. <BODY  bgcolor="#FFFFD5">
  9.     
  10. <H3>ArrayAvg Example</H3>
  11. <P>
  12. This view-only example uses ArrayAvg
  13. to determine the average of the elements
  14. in an array.
  15. <P>
  16. See the View Example pane to view the code.
  17. <!--- create an array --->
  18. <!---
  19. <CFSET myNumberArray = ArrayNew(1)>
  20. --->
  21. <!--- run a standard search --->
  22. <!---
  23.   <CFSEARCH NAME="SearchSnippets"
  24.         COLLECTION="snippets"
  25.         TYPE="simple"
  26.         CRITERIA="Array*">
  27. --->
  28. <!--- 
  29. <CFSET temp = 1>
  30. --->
  31. <!--- output the results of the search --->
  32. <!---
  33. <CFOUTPUT QUERY="SearchSnippets">
  34.     <CFSET myNumberArray[temp] = score>
  35. <CFSET temp = temp + 1>
  36. </CFOUTPUT>
  37. --->
  38. <!--- use ArrayAvg to get the average score --->
  39. <!---
  40. <P>The average score for your search on the term
  41. "Array*" in the collection "Snippets" is 
  42. <CFOUTPUT>#ArrayAvg(myNumberArray)# for
  43. #SearchSnippets.RecordCount# "hits"<BR>
  44. </CFOUTPUT>
  45. --->
  46.  
  47. </BODY>
  48. </HTML>       
  49.